/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package samoloty.view;

import java.awt.Font;
import java.awt.Point;
import javax.swing.JComboBox;

/**
 *
 * @author frankowp
 */
public class MyComboBox extends JComboBox {

    public final static int NORMAL = 1;
    public final static int BOLD = 2;

    public MyComboBox() {
        super();
        initComboBox();
        this.setFocusable(false);

    }

    public MyComboBox(Object[] items) {
        super(items);
        initComboBox();
        setMaximumRowCount(items.length);
    }

    public MyComboBox(Object[] items, int style) {
        super(items);
        initComboBox();
        if (style == NORMAL) {
            setNormal();
        } else {
            setBold();
        }
        setMaximumRowCount(items.length);
    }

    private void initComboBox() {
       
        setScrollBar();
        setNormal();
        setGrey();
        setOpaque(true);
        setAlignmentX(CENTER_ALIGNMENT);
        /*UIManager.put("ScrollBar.thumb", MyColors.getBlack());
        UIManager.put("ScrollBar.thumbShadow", MyColors.getBlack());
        UIManager.put("ScrollBar.thumbHighlight", MyColors.getBlack());
        UIManager.put("ScrollBar.darkShadow", MyColors.getBlack());
        UIManager.put("ScrollBar.background", MyColors.getBlack());
        UIManager.put("ScrollBar.track", MyColors.getBlack());
        UIManager.put("ScrollBar.trackHighlight ", MyColors.getBlack());*/



        
    }

    public void setGrey() {
        //this.setForeground(MyColors.getGrey());
        this.setBackground(new java.awt.Color(0, 0, 0));
        this.setForeground(MyColors.getWhite());
        }

    public void setBold() {
        this.setFont(new Font("Tahome", Font.BOLD, 16));
    }

    public void setNormal() {
        this.setFont(new Font("Tahome", 0, 16));
    }

    

    public void setPosition(Point p) {
        this.setBounds(p.x, p.y, getPreferredSize().width, getPreferredSize().height);
    }

    public void setPositionByRight(Point p) {
        this.setBounds((int) (p.x - getPreferredSize().width), p.y, getPreferredSize().width, getPreferredSize().height);
    }

    public void setScrollBar(){
       setUI(new MyComboBoxUI());
    }
}
